var common = require('../../../utils/common.js');
Page({
  data: {
    condition: {
      skip: 0,
      take: 10
    },
    activities: []
  },
  type: 1,
  onLoad: function (options) {
    this.registerEvent();
    this.type = options.type;
  },
  registerEvent: function () {
    this.reqActivities(this.type);
  },
  reqActivities: function (type) {
    let that = this;
    common.asynPost(common.API.activity.activities, {
      type: type,
      skip: that.data.condition.skip,
      take: that.data.condition.take
    }, function (data) {
      if (data['activities']) {
        that.setData({
          activities: data['activities']
        });
      }
    });
  },
  handleActiveDetail: function (e) {
    let that = this, id = e.currentTarget.dataset.id;
    if(that.type == 1){
      wx.navigateTo({
        url: '../../activity/detail/detail?id=' + id
      })
    }else{
      wx.navigateTo({
        url: '../../activity/special/special?id=' + id
      })
    }
  }
})